<?php
declare (strict_types = 1);

namespace app\admin\controller;

use addons\Builder\facade\Builder;
use think\response\Json;
use app\common\tool\Result;
//该文件为自动生成，请按需修改
class Merchant extends Base
{
    //主键，默认为id
    protected string $pk = 'id';
    //关联模型
    protected $hasOne = ['user'];

    //主模型
    protected string $model = '\app\common\model\Merchant';
    
    protected int $takeOver = 3;
    public function index(): string
    {
       return Builder::Table()
           ->autoStructure($this->model, $this->pk, 'barDemo,200')
           ->addRightButtons(['edit' => ['title' => '查看', 'unity_title' => '审核/查看', 'size' => '60%']])
           ->addTopButtons([
            //    'batchAudit' => [
            //        'title' => '批量审核', 'icon' => 'layui-icon-util',
            //        'url'   => url('merchant/batch')->build(),
            //        'event' => '_batchSubmit'
            //    ]
           ])
           ->addSearch([
               ['uid', '会员编号/昵称/手机号', 'input', '', '\app\common\model\User', 'code|nickname|mobile,id']
           ])
           ->fetch();
    }
    
    public function edit($id = '', $tpl = 'merchant/edit', $info = ''): string
    {
        return parent::edit($id, $tpl, $info); // TODO: Change the autogenerated stub
    }

    public function save($param = [], $model = true): Json
    {
        return parent::save($param, $model); // TODO: Change the autogenerated stub
    }

    public function batch()
    {
        return Result::fastReturn($this->model::batch($this->request->param('ids'), $this->admin));
    }
}
